package org.ainlolcat.ctp.controller;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.ainlolcat.ctp.model.configuration.Configuration;
import org.ainlolcat.ctp.model.data.Entity;
import org.ainlolcat.ctp.module.Container;
import org.ainlolcat.ctp.module.Module;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: ain
 * Date: 07.09.12
 * Time: 12:05
 * To change this template use File | Settings | File Templates.
 */
@Singleton
public class DogmaImpl implements Dogma{
    Configuration configuration;
    @Inject
    Container container;

    public void setConfiguration(Configuration configuration) {
        this.configuration = configuration;
        container.setConfiguration(configuration);
    }

    public void push(Entity entity) {
        List<Module> modules = container.getSubscribers(entity.getInternalName());
        for (Module module : modules){
            module.push(entity);
        }
    }
}
